/*
 * 数组选择排序
 * */
public class SelectSort {
    public static void main(String[] args) {
        int[] arr = {1, 2, 4, 5, 3, 5, 7, 9, 5, 43, 10};
        selectSort(arr);
        printArray(arr);
    }

    // 数组选择排序
    public static void selectSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[i] > arr[j]) {
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }
    // 打印数组
    public static void printArray(int[] arr) {
        String ret = "[";
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                ret += arr[i] + "]";
            } else {
                ret += arr[i] + "、";
            }
        }
        System.out.println(ret);
    }
}